<html>
<script type="text/javascript">
function login()
{
	//debugger;
	str_loginname = document.getElementById("loginname").value;
	str_password = document.getElementById("password").value;
	bit_savecookie = document.getElementById("savecookie").checked;

	if(str_loginname.length ==0 )
	{
		document.getElementById("loginnameHint").innerHTML ="<font color='red'>Please fill in the LoginName!</font>";
		return;
	}

	if(str_password.length ==0)
	{
		document.getElementById("passwordHint").innerHTML ="<font color='red'>Please fill in the Password!</font>";
		return;
	}

	checkPassword(str_loginname,str_password,bit_savecookie);
	
}

function checkPassword(loginname,password,savecookie)
{
	// code for IE7+, Firefox, Chrome, Opera, Safari
 	xmlhttp=new XMLHttpRequest();
	xmlhttp.open("GET","./dataLogic/login.php?name="+loginname+"&pwd="+password+"&savecookie="+savecookie,false);
	xmlhttp.send();
	//alert(xmlhttp.responseText);
	
	if(xmlhttp.responseText == "Login succeed")
	{
		window.location = "./main.php"
	}
	else
	{
		document.getElementById("loginHint").innerHTML ="<font color='red'>Login failed! Wrong loginname or password !</font>";
		return;
	}
}
</script>

<body>
<div>
<form>

<p>LoginName:<input id="loginname" name="loginname" type="text" />
<span id="loginnameHint"></span>	
</p>

<p>Password:<input id="password" name="password" type="password" />
<span id="passwordHint"></span>
</p>

<input type="button" value="Login" onclick="login()"/>

<label >Remember me <input id="savecookie" type="checkbox" /> </label>
<span id="loginHint"></span>

</form>
</div>

</body>
</html>